package com.epam.facebook_client;

import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.epam.facebook_client.fragment.HeadFragment;
import com.epam.facebook_client.fragment.ProfileFragment;

public class ProfileActivity extends FragmentActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Bundle extras = getIntent().getExtras();
		if (!extras.getString("id").equals(getSharedPreferences(HeadFragment.MY_ID, 0).getString(HeadFragment.ID, null))) {
			if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
				finish();
				return;
			}
		}
		if (savedInstanceState == null) {
			ProfileFragment profile = new ProfileFragment();
			profile.setArguments(getIntent().getExtras());
			getSupportFragmentManager().beginTransaction().add(android.R.id.content, profile).commit();
		}

	}
}
